{include file='admin/header.html'}


	  <span class="td4"> 
          <div class="botline"></div>
          <div class="filtrs"> Фильтр
  <form method="post" action="{geturl action='users'}" id="filter-form">

    <select name='cats_filter[]' id='cats_filter' data-placeholder="Выбрать категорию" class="chosen-select_cat" multiple style="width:150px;" tabindex="4">
<option value="0" ></option>
{foreach from=$cats item=cat}
{if in_array($cat->getId(),$cats_filter)}
<option value="{$cat->getId()}" selected='selected'>{$cat->name}</option>
{else}
<option value="{$cat->getId()}">{$cat->name}</option>
{/if}
{/foreach}
</select>

<select name='region_filter' id='region_filter' onchange="region_city()" data-placeholder="Выбрать область" class="chosen-select_project" style="width:170px;" tabindex="4">
<option value=''>Все</option>
{foreach from=$regions item=region}
{if $region->getId()== $region_filter}
<option value="{$region->getId()}" selected='selected'>{$region->name}</option>
{else}
<option value="{$region->getId()}">{$region->name}</option>
{/if}
{/foreach}
</select>      
      <span id="cities">{if $cities}
<select name='city_filter' id='city_filter' data-placeholder="Выбрать город" class="chosen-select_city" style="width:170px;" tabindex="4">
<option value='0'></option>
{foreach from=$cities item=city}
{if $city->getId()== $city_filter}
<option value="{$city->getId()}" selected='selected'>{$city->name}</option>
{else}
<option value="{$city->getId()}">{$city->name}</option>
{/if}
{/foreach}
</select>
  {/if}
      </span>
   
<select name='archive_filter' id='projects_filter' data-placeholder="Показывать все" class="chosen-select_project" style="width:150px;" tabindex="4">
{if $archive_filter == ''}
<option value="2" selected='selected'>Все</option>
{else}
<option value="2">Все</option>
{/if}

{if $archive_filter == 1}
<option value="1" selected='selected'>Активные</option>
{else}
<option value="1">Активные</option>
{/if}

{if $archive_filter == 0}
<option value="0" selected='selected'>Не активные</option>
{else}
<option value="0">Не активные</option>
{/if}

</select>   
          <button type="submit" class="send">Фильтр</button>
             
       
    </form>
        </div>
        <div class="botline"></div>
    <table class="tdzayavki">
          <thead>
            <tr> 
              <td class="tb1">
              {if $sort=='login'}
            <a href="?sort=login&order={if $order=='desc'}asc{else}desc{/if}" class="{$order}">Логин</a>
            {else}
            <a href="?sort=login&order={if $order=='desc'}asc{else}desc{/if}">Логин</a>
            {/if}
              </td>
              <td class="tb2">
               {if $sort=='company'}
            <a href="?sort=company&order={if $order=='desc'}asc{else}desc{/if}" class="{$order}">Предприятие</a>
            {else}
            <a href="?sort=company&order={if $order=='desc'}asc{else}desc{/if}">Предприятие</a>
            {/if}
              </td>
              <td class="tb3">
               {if $sort=='manager'}
            <a href="?sort=manager&order={if $order=='desc'}asc{else}desc{/if}" class="{$order}">Контактное лицо</a>
            {else}
            <a href="?sort=manager&order={if $order=='desc'}asc{else}desc{/if}">Контактное лицо</a>
            {/if}
              </td>
              <td class="tb4">
                 {if $sort=='isApproved'}
            <a href="?sort=c.isApproved&order={if $order=='desc'}asc{else}desc{/if}" class="{$order}">Статус</a>
            {else}
            <a href="?sort=c.isApproved&order={if $order=='desc'}asc{else}desc{/if}">Статус</a>
            {/if}
              </td>
              <td class="tb5">Действие</td>
            </tr>
          </thead>

    {foreach from=$users item='user'}
   {if $user->type != 'globaladmin' || $identity->type == 'globaladmin'}
   <tr id="tr_{$user->getId()}">
        <td class="nocontainer fs12" id="name_{$user->getId()}">{$user->login}</td>
        <td>{$user->company}</td>
        <td class="nocontainer">{$user->manager}</td>
       <td >
            {if $user->isApproved != 1}
            <img src="/images/index-07.png" id="img_{$user->getId()}" alt="" class="noborders">
           
            {else}
            <img src="/images/index-08.png" id="img_{$user->getId()}" alt="" class="noborders">
            {/if}
        </td>
           <td>
               <a href="{geturl route='edituser' id=$user->getId()}"><img src="/images/index-14.png" alt="Редактировать"></a>
                <a onclick="deleteuser({$user->getId()});" style="cursor: pointer"><img src="/images/index-07.png" alt="Удалить"></a>
                 <a  id="app_{$user->getId()}" onclick="approveuser({$user->getId()},{$user->isApproved})">
                     {if !$user->isApproved} <img src="/images/approve.png" alt="Одобрить" title="Одобрить" />{else} <img src="/images/block.png" alt="Заблокировать" title="Заблокировать" />{/if}</a>
           </td>
      
    </tr>
{/if}
    {/foreach}  
        </table>
      {if $pages != 1}
      <div class="pages">
            {section loop=$pages name=page}
                {assign var=p value=$smarty.section.page.index_next}
                {if $p == $page}
                    <span>{$p}</span>
                {else}
                   {if $p==1}
                    <a href="{geturl action='users'}">{$p}</a>
                    {else}
                     <a href="{geturl action='users'}?p={$p}">{$p}</a>
                    {/if}
                 
                {/if}
            {/section}
        </div>
      {/if}
        </span> 

{include file='admin/footer.html' menu="users"}